<%@ include file="/common/taglibs.jsp"%>
<%@ page import="org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices" %>
<%@ page import="javax.servlet.http.Cookie" %>
<%@ page import="com.xyzh05.webapp.util.RequestUtil" %>

<%
	if (request.getSession(false) != null) {
	    session.invalidate();
	}
	Cookie terminate = new Cookie(TokenBasedRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, null);
	String contextPath = request.getContextPath();
	terminate.setPath(contextPath != null && contextPath.length() > 0 ? contextPath : "/");
	terminate.setMaxAge(0);
	response.addCookie(terminate);
	
	Cookie userIdCookie = RequestUtil.getCookie(request, "userId");
	Cookie loginDateCookie = RequestUtil.getCookie(request, "loginTime");
	Cookie caCookie = RequestUtil.getCookie(request, "ca");
	
	RequestUtil.deleteCookie(response, userIdCookie, "/");
	RequestUtil.deleteCookie(response, loginDateCookie, "/");
	RequestUtil.deleteCookie(response, caCookie, "/");
%>

<c:redirect url="/mainMenu.html"/>